package mo.leetcode_top;

public class L387 {

    public int firstUniqChar(String s) {
        byte[] counts = new byte[26];
        for (int i = 0; i < s.length(); i++) {
            char c = s.charAt(i);
            if (counts[c-'a'] <= 1) {
                counts[c-'a']++;
            }
        }
        for (int i = 0; i < s.length(); i++) {
            if (counts[s.charAt(i)-'a'] == 1) {
                return i;
            }
        }
        return -1;
    }

}
